Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tunnel manager to not return error for configuration loading #5188

Conversation

rablador
Copy link
Contributor

@rablador rablador commented Sep 22, 2023

It seems we have sufficient handling of cases where we cannot load the config we need. The current path does not allow the load config operation to return a failure/error, so we cannot end up with a thrown fatalError unless there's an implementation error.


This change is Reviewable

@rablador rablador added the iOS Issues related to iOS label Sep 22, 2023
@linear
Copy link

linear bot commented Sep 22, 2023

IOS-297 Failed tunnel manager init should show problem report view

Function getInitTunnelManagerOperation() throws a fatal error if tunnel manager cannot load config. We should show the problem report view instead.

The code in question:

private func getInitTunnelManagerOperation() -> AsyncBlockOperation {
    AsyncBlockOperation(dispatchQueue: .main) { finish in
        self.tunnelManager.loadConfiguration { error in
            if let error {
                fatalError(error.localizedDescription)
            }
    [...]
}

Copy link
Contributor

@pronebird pronebird left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 2 files at r1.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

Copy link
Contributor

@buggmagnet buggmagnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 2 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @rablador)


ios/MullvadVPN/AppDelegate.swift line 439 at r1 (raw file):

        AsyncBlockOperation(dispatchQueue: .main) { finish in
            self.tunnelManager.loadConfiguration { error in
                if let error {

I don't think we should be dismissing the error and completely ignore it. This means we will continue operation as if nothing happened, but we will most likely be running in an invalid state, which probably means nothing will work as expected.

I suggest to log the error at least so future ourselves can have a clue about what's happening.

The best would be to trigger a way to have loadConfiguration return an error in a real use scenario so we can understand which cases error out, and act accordingly.

Copy link
Contributor Author

@rablador rablador left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @pronebird)


ios/MullvadVPN/AppDelegate.swift line 439 at r1 (raw file):

Previously, buggmagnet wrote…

I don't think we should be dismissing the error and completely ignore it. This means we will continue operation as if nothing happened, but we will most likely be running in an invalid state, which probably means nothing will work as expected.

I suggest to log the error at least so future ourselves can have a clue about what's happening.

The best would be to trigger a way to have loadConfiguration return an error in a real use scenario so we can understand which cases error out, and act accordingly.

The thing is that this error is misleading to being with. We always treat the operation as successful here and handle state changes elsewhere. According to @pronebird, "worst case if we can’t read settings or device state, we simply pretend they are not there and leave user in logged out state". Also, VPN config will be removed, meaning you'll get another try and system settings prompt when trying to connect later again.

Copy link
Contributor

@buggmagnet buggmagnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @pronebird)


ios/MullvadVPN/AppDelegate.swift line 439 at r1 (raw file):

Previously, rablador (Jon Petersson) wrote…

The thing is that this error is misleading to being with. We always treat the operation as successful here and handle state changes elsewhere. According to @pronebird, "worst case if we can’t read settings or device state, we simply pretend they are not there and leave user in logged out state". Also, VPN config will be removed, meaning you'll get another try and system settings prompt when trying to connect later again.

All right fair enough, would you mind adding a summary of this as a comment in here and we can merge this ?

Copy link
Contributor Author

@rablador rablador left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @pronebird)


ios/MullvadVPN/AppDelegate.swift line 439 at r1 (raw file):

Previously, buggmagnet wrote…

All right fair enough, would you mind adding a summary of this as a comment in here and we can merge this ?

Sure thing. 👍

@rablador rablador force-pushed the failed-tunnel-manager-init-should-show-problem-report-view-ios-297 branch from 25a9e6a to 5b9f9d9 Compare September 25, 2023 13:09
@buggmagnet buggmagnet force-pushed the failed-tunnel-manager-init-should-show-problem-report-view-ios-297 branch from 5b9f9d9 to c10006e Compare September 25, 2023 13:12
@buggmagnet buggmagnet merged commit 77b7423 into main Sep 25, 2023
4 checks passed
@buggmagnet buggmagnet deleted the failed-tunnel-manager-init-should-show-problem-report-view-ios-297 branch September 25, 2023 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iOS Issues related to iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants